<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 520px;
            height: 160px;
            border: 5px solid #000;
            margin: 50px auto;

            display: flex;
            justify-content: space-evenly;
            align-items: center;
        }
        .box p{
            width: 100px;
            height: 100px;
        }
        img{
            width: 100%;
            height: 100%;
            display: block;
        }
        .imgBox{
            width: 200px;
            height: 200px;

            pointer-events: none;

            display: none;

            position: fixed;
            top: 0;
            left: 0;
        }
    </style>
</head>
<body>
    <div class="box">
        <p><img src="./img/1.png" alt=""></p>
        <p><img src="./img/2.png" alt=""></p>
        <p><img src="./img/3.png" alt=""></p>
    </div>
    <div class="imgBox">
        <img src="./img/1.png" alt="">
    </div>
    <script src="./js/jquery.min.js"></script>
    <script>
        $(".box p").hover(
            //鼠标移入到p标签
            //1. 显示imgBox盒子
            //2. 获取鼠标移动的坐标
            //3. 让盒子跟着鼠标   
            //4. 获取p标签里面图片的src
            //5. 将获取到的src的图片路径赋值imgBox里面的图片         
            function(e){
                //1.显示imgBox
                $(".imgBox").show(50)
                /* 鼠标移动事件 */
                $(".box p").mousemove(function(e){
                    //设置imgBox跟随鼠标的坐标进行移动
                    $(".imgBox").css({"top":e.pageY,"left":e.pageX})
                })
                //怎么获取儿子
                // console.log($(this).find('img').attr('src'));
                //赋值给imgBox下面的img
                $(".imgBox").find("img").attr("src",$(this).find('img').attr('src'));
            },
            //鼠标移出p标签
            function(){
                $(".imgBox").hide(50)
            }
        )
    </script>
</body>
</html>